﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Data;
using System.Windows.Forms;
using System.Threading;
namespace Typing_GUI.CLASS
{
    public enum LessonTypes { Text = 1, Adventure = 2 };
    public class DataProvider
    {
        public static string AvatarFolderPath="images/Avatar/";
        public static string LevelFolderPath = "images/CapDoNguoiDung/";
        static string DatabasePath = "Database/DatabaseTyper2003.mdb";
        /* Tạo chuỗi kết nối */
        static string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+DatabasePath;
        static OleDbConnection conn=new OleDbConnection(strConnection);
        /* Hàm truy vấn trả về bảng dữ liệu */
        public static DataTable  ExecuteQuery(string sql)
        {
            DataTable kq=new DataTable();
            conn.Open();
            OleDbDataAdapter adapter = new OleDbDataAdapter(sql,conn);
            adapter.Fill(kq);
            conn.Close();
            return kq;
        }
        /*Hàm thực thi truy vấn không trả về dữ liệu */
        public static bool ExecuteNonQuery(string sql)
        {
            bool kq = true;
            try
            {
                conn.Open();
                OleDbCommand command = new OleDbCommand(sql, conn);
                command.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
            return kq;
        }
        /*Hàm thao tác đóng và mở cửa sổ Form
         */
       
        
       
    }
}
